using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Sudoku.Lang;

namespace Services
{
	public class TextureLibrary
	{
		protected Dictionary<string, Texture2D> logo;
		protected Dictionary<string, Texture2D> background;
		protected Dictionary<string, Texture2D> texture;
		protected Dictionary<string, Texture2D> howto;

		private ContentManager content;

		public TextureLibrary(ContentManager content)
		{
			background = new Dictionary<string, Texture2D>();
			texture = new Dictionary<string, Texture2D>();
			howto = new Dictionary<string, Texture2D>();

			logo = new Dictionary<string, Texture2D>();

			this.content = content;
		}

		public void LoadLogos()
		{
			logo.Add("BoredSnail", content.Load<Texture2D>("Graphics/Logos/boredsnail"));
			logo.Add("VST", content.Load<Texture2D>("Graphics/Logos/vst"));
		}

		public void LoadBGs(int i)
		{
			//Load Background
			switch(i)
			{
				case 1:
					background.Add("General", content.Load<Texture2D>("Graphics/Backgrounds/menu2"));
					background.Add("Main", content.Load<Texture2D>("Graphics/Backgrounds/menu1"));
					break;
				
				case 2:
					background.Add("BlueKarp", content.Load<Texture2D>("Graphics/Backgrounds/EndGame/BlueKarp"));
					texture.Add("BlueHint", content.Load<Texture2D>("Graphics/Backgrounds/EndGame/BlueHint"));
					texture.Add("BlueTime", content.Load<Texture2D>("Graphics/Backgrounds/EndGame/BlueTime"));
					texture.Add("BlueTot", content.Load<Texture2D>("Graphics/Backgrounds/EndGame/BlueTot"));
					background.Add("GoldKarp", content.Load<Texture2D>("Graphics/Backgrounds/EndGame/GoldKarp"));
					texture.Add("GoldHint", content.Load<Texture2D>("Graphics/Backgrounds/EndGame/GoldHint"));
					texture.Add("GoldTime", content.Load<Texture2D>("Graphics/Backgrounds/EndGame/GoldTime"));
					texture.Add("GoldTot", content.Load<Texture2D>("Graphics/Backgrounds/EndGame/GoldTot"));
					texture.Add("Equal", content.Load<Texture2D>("Graphics/Backgrounds/EndGame/Equal"));
					texture.Add("Plus", content.Load<Texture2D>("Graphics/Backgrounds/EndGame/Plus"));
					texture.Add("X", content.Load<Texture2D>("Graphics/Backgrounds/EndGame/X"));
					background.Add("Sudoku", content.Load<Texture2D>("Graphics/Backgrounds/grid"));
					
					break;

				default:
					break;
			}
		}

		public void LoadTextures(int i)
		{
			//Load game elements textures
			switch (i)
			{
				case 1:
					texture.Add("Button1", content.Load<Texture2D>("Graphics/Texture/Buttons/bottone"));
					texture.Add("Button2", content.Load<Texture2D>("Graphics/Texture/Buttons/bottone2"));
					texture.Add("Credits", content.Load<Texture2D>("Graphics/Texture/Buttons/credits"));
					texture.Add("Eraser", content.Load<Texture2D>("Graphics/Texture/Buttons/eraser"));
					texture.Add("Guess", content.Load<Texture2D>("Graphics/Texture/Buttons/guess"));
					texture.Add("Hint", content.Load<Texture2D>("Graphics/Texture/Buttons/hint"));
					//SUDOKU MASTER ADS
#if !SUDOKU_MASTER
					texture.Add("Ads", content.Load<Texture2D>("Graphics/Ads/ads" + LocalizedStrings.Language));
#endif
					break;
				
				case 2:
					texture.Add("HintNumbers", content.Load<Texture2D>("Graphics/Texture/hintNumbers"));
					texture.Add("NewGame", content.Load<Texture2D>("Graphics/Texture/Buttons/newgame"));
					texture.Add("Numbers", content.Load<Texture2D>("Graphics/Texture/numbers"));
					texture.Add("Quit", content.Load<Texture2D>("Graphics/Texture/Buttons/quit"));
					texture.Add("Reset", content.Load<Texture2D>("Graphics/Texture/Buttons/reset"));
					texture.Add("WhiteFill", content.Load<Texture2D>("Graphics/Texture/whiteFill"));
					texture.Add("Pellicano", content.Load<Texture2D>("Graphics/Texture/pellicano"));
					break;

				default:
					break;
			}
		}

		public void LoadHowToGraphics(string language)
		{
			// How-to Scene related..
			howto.Add("HOWTO_01", content.Load<Texture2D>("Graphics/Howto/" + language + "/howto_01"));
			howto.Add("HOWTO_02", content.Load<Texture2D>("Graphics/Howto/" + language + "/howto_02"));
			howto.Add("HOWTO_03", content.Load<Texture2D>("Graphics/Howto/" + language + "/howto_03"));
			howto.Add("HOWTO_04", content.Load<Texture2D>("Graphics/Howto/" + language + "/howto_04"));
		}

		public bool LogoExists(string name)
		{
			return logo.ContainsKey(name);
		}

		public Texture2D Logo(string name)
		{
			return logo[name];
		}

		public bool BackgrounExists(string name)
		{
			return background.ContainsKey(name);
		}

		public Texture2D Background(string name)
		{
			return background[name];
		}

		public bool TextureExists(string name)
		{
			return texture.ContainsKey(name);
		}

		public Texture2D Texture(string name)
		{
			return texture[name];
		}

		public bool HowtoExists(string name)
		{
			return howto.ContainsKey(name);
		}

		public Texture2D Howto(string name)
		{
			return howto[name];
		}
	}
}
